// Directly's Real Time Messaging (RTM) widget is an on-demand customer support tool.
// Read more about the RTM widget and how it's used in Calypso in the `lib/directly` README.
//
// The RTM widget loads in an iframe, so we can't adjust the widget's internal styles
// with the primary Calypso stylesheet. This file is bundled as a separate CSS file to be
// linked from inside the widget's iframe.
//
// We have two Directly builds — Production and Sandbox. Directly requires that all
// custom CSS files exist at a public web address, and these can't change on-the-fly
// based on the Calypso environment. So the CSS files Directly uses are hard-set to:
//
// Sandbox:    https://wpcalypso.wordpress.com/calypso/directly.css
// Production: https://wordpress.com/calypso/directly.css
//
// ## DEVELOPMENT ENVIRONMENT INSTRUCTIONS:
//
// Calypso's development environment uses the Sandbox Directly build, which requests custom
// CSS from the wpcalypso server. This means that to see local CSS changes you'll need to
// make your browser rewrite those CSS URLs to the local version:
//
// https://wpcalypso.wordpress.com/calypso/directly.css -> http://calypso.localhost:3000/calypso/directly.css
//
// You can accomplish this using a browser extension such as Switcharoo Redirector
// for Chrome: https://chrome.google.com/webstore/detail/switcheroo-redirector/cnmciclhnghalnpfhhleggldniplelbg
//
// An unfortunate side-effect is that the widget's iframe src is https, but this local
// CSS file is http. So most browsers will block the CSS by default to prevent mixed
// content. In order to see the custom CSS you will need to temporarily allow insecure
// content on the page. In Chrome for Mac you can issue this Terminal command:
//
// open -a Google\ Chrome --args --allow-running-insecure-content
//
// QUIT AND RESTART YOUR BROWSER NORMALLY WHEN YOU'RE DONE MAKING LOCAL CSS CHANGES.

@import 'shared/mixins/mixins';
@import 'shared/colors';
@import 'shared/forms';
@import 'shared/typography';

* {
	font-family: $sans;
}

body {
	color: $gray-dark;
	-webkit-font-smoothing: subpixel-antialiased;
}

html,
input,
select,
textarea {
	font-family: $sans;
}

// Main button
.btn {
	background: $blue-medium;
	border: 1px solid darken( $blue-medium, 8% );
	color: $white;
	border-width: 1px 1px 2px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 500;
	vertical-align: top;
	box-sizing: border-box;
	line-height: 21px;
	border-radius: 4px;
	padding: 7px 14px 9px;
	appearance: none;
	width: auto;
	&:hover {
		border-color: $blue-dark;
	}
	&:active,
	&:active:enabled {
		outline: 0;
		border-width: 2px 1px 1px;
		padding: 7px 14px 9px;
		color: $white;
	}
	&:focus {
		border-color: $blue-dark;
		box-shadow: 0 0 0 2px $blue-light;
	}
}

// Form inputs
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="url"],
textarea {
	@extend %form-field;
	-webkit-font-smoothing: subpixel-antialiased;

	&::-webkit-input-placeholder {
		color: $gray;
	}

}
textarea {
	vertical-align: inherit;
}

.minimized-view,
.maximized-view {
	background: #F2F6F8;
}
.minimized-view {
	background: $white;
	box-shadow: 0 1px 10px rgba(46,68,83,.1);
	border: 1px solid lighten( $gray, 25% );
}
.maximized-view.is-ask-view {
	top: 0;
}
.message-list-transition-wrapper {
	background: #F2F6F8;
}


/* HEADER */

.header-container {
	border-bottom: 1px solid lighten( $gray, 30% );
	box-shadow: none;
	flex: 0 0 32px;
	height: 32px;

	.header-title {
		text-transform: uppercase;
		font-size: 11px;
		font-weight: 700;
		color: $gray;
	}

	// Left hamburger button
	.menu {
		border-right: none;
		flex: 0 0 40px;
		.svg-icon {
			color: $gray;
		}
		&.disabled {
			background: transparent;
			.svg-icon {
				color: lighten( $gray, 25% );
			}
		}
	}

	// Right minimize button
	.minimize-container {
		border-left: none;
		flex: 0 0 40px;
		.svg-icon {
			color: $gray;
		}
	}

	.thread-view-title-container {
		&.has-notification {
			border-bottom-color: #14abdd;
		}
	}
}


/* CHAT LIST (opens with the hamburguer button on header) */

.chat-list-view-container {
	.chat-list-container {
		top: 32px;
		.question-bar,
		.question-bar.closed {
			background: $gray;
			padding: 10px 14px;
		}
	}
}

.chat-list-view-item-container {
	background: lighten( $gray, 30% );
	border-bottom: 1px solid lighten( $gray, 25% );
	color: $gray-dark;
	padding: 18px 10px 18px 24px;
	.chat-list-item-title {
		margin-bottom: 2px;
		font-size: 16px;
	}
	.chat-list-item-meta {
		color: $gray;
	}
	.unread-message-dot {
		background: $alert-green;
		left: 10px;
		top: 25px;
	}
}

// Bubble when the chat list is minimized
.chat-list-view-minimized {
	.chat-list-status {
		margin-top: 2px;
	}
	.svg-icon {
		color: $blue-medium;
	}
}


/* ASK QUESTION (opens from chat list) */

.ask-question-form-container {
	.input-group {
		padding-bottom: 12px;
		margin-top: 0;
		label {
			text-transform: none;
			font-size: 14px;
			font-weight: 600;
			margin-bottom: 5px;
			strong {
				font-weight: inherit;
			}
		}
	}
	.submit {
		width: 100%;
		padding-bottom: 9px;
		.svg-icon {
			display: none;
		}
		strong {
			margin-top: 0;
			font-weight: 500;
		}
	}
}


/* THREAD */

.thread-view-container {
	.expert-response-time {
		color: $gray;
	}
}

// Message bubbles
.message-container {
	font-size: 14px;
	border-radius: 8px;

	&.is-poster {
		background: #14abdd;
		margin-left: inherit;
		margin-right: 20px;
		border-top-right-radius: 0px;
		position: relative;
		&:after {
			// Triangle for the corner
			position: absolute;
				top: 0;
				right: -10px;
			content: "";
			display: block;
			width: 0;
			height: 0;
			border-style: solid;
			border-width: 10px 10px 0 0;
			border-color: #14abdd transparent transparent transparent;
		}
	}

	&.is-expert {
		border: none;
		border-radius: 8px;
		border-top-left-radius: 0;
		margin-right: inherit;
		margin-left: 20px;
		position: relative;
		&:after {
			// Triangle for the corner
			position: absolute;
				top: 0;
				left: -10px;
			content: "";
			display: block;
			width: 0;
			height: 0;
			border-style: solid;
			border-width: 0 10px 10px 0;
			border-color: transparent $white transparent transparent;
		}
		.author img {
			// Need to override inline styles with !importants
			width: 32px !important;
			height: 32px !important;
		}
	}
}

// Avatar + name + reputation, used inside .message-container.is-expert
.author {
	.name-wrapper {
		font-size: 12px;
		font-weight: 500;
	}
	.profile .reputation {
		color: lighten( $gray, 10% );
	}
}
.avatar {
	background: lighten( $gray, 25% );
}

.system-message {
	border: 1px solid lighten( $gray, 25% );
	background: lighten( $gray, 30% );
	font-size: 14px;
	margin-right: 0;
	border-radius: 8px;
	&.has-sibling + .system-message {
		border-top: 1px solid lighten( $gray, 25% );
	}

	// Green border for success messages
	&.success {
		border-color: $alert-green;
		background: #DCEEE5;
	}

	// Green background for highlighted success messages
	&.success.inverted {
		border-color: transparent;
		background: $alert-green;
		color: $white;
		a {
			color: $white;
		}
	}

	// Yellow borders for warnings
	&.warning {
		background: $alert-yellow;
		border-color: transparent;
		color: $white;
		a {
			color: $white;
		}
	}

	// Placeholder displayed when the experts info is loading
	&.alerting-experts {
		.expert-name:empty {
			background: lighten( $gray, 25% );
		}
		.expert-last-active-date {
			color: $gray;
			&:empty {
				background: lighten( $gray, 25% );
			}
		}
	}

	.icon-avatar {
		background: lighten( $gray, 25% );
	}

	// Icons inside system messages
	.icon {
		margin-top: 0;
		&.icon-primary {
			background-color: #14abdd;
		}
		&.icon-success {
			background-color: $white;
			color: $alert-green;
		}
		&.icon-warning {
			background-color: $white;
			color: $alert-yellow;
		}
	}
	&.inverted .icon.icon-success {
		background-color: $white;
		color: $alert-green;
	}
}

// When nobody has answered a question yet, a carousel of last available experts is shown
.expert-carousel {
	box-shadow: none;
}

// Reply box and other tools in the thread view footer
.thread-view-footer {
	border-top: 1px solid lighten( $gray, 30% );
	box-shadow: none;
	background: $white;
}

// Bubble when the thread view is minimized
.chat-view-minimized {
	// When no expert has replied yet
	.alerting {
		color: $gray;
		.beacon {
			background: $blue-wordpress;
			margin: 5px auto;
			&:after {
				background: $blue-wordpress;
			}
		}
	}

	// When there's a chat going on
	.chatting img {
		height: 64px;
		width: 64px;
	}
	.notification {
		background: $blue-medium;
		font-size: 12px;
		font-weight: 500;
		min-width: 24px;
		line-height: 24px;
		margin-top: -3px;
		margin-left: -3px;
	}
}

// Chat box
.message-form-container {
	.message-input {
		padding-right: 10px;
		align-self: center;
	}
	textarea:focus {
		box-shadow: none;
	}
	.submit-btn[disabled] {
		background-color: lighten( $gray, 25% );
		border: none;
	}
}

// Tools inside chat box
.toolbar-accepted-container,
.toolbar-default-container,
.toolbar-rate-container {
	border-top: 1px solid lighten( $gray, 30% );
}
.toolbar-container {
	.tooltip-wrapper {
		border-left: 1px solid lighten( $gray, 30% );
	}
	.toolbar-btn {
		color: $gray;
		border-left: 1px solid lighten( $gray, 30% );
		.svg-icon {
			color: $alert-green;
		}
	}
	.rate-icon {
		.dot {
			&.dot-green {
				background: $alert-green;
			}
			&.dot-yellow {
				background: $alert-yellow;
			}
			&.dot-red {
				background: $alert-red;
			}
		}
	}
}

// Displays when the user wants to accept the answer
.ActionBar {
	background: $white;
}
.ActionBar__button {
	box-shadow: none;
	&:hover {
		box-shadow: none;
		transform: none;
	}
}
